package com.bangcommunity.bbframe.sdm.aop.handler;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

/**
 *
 * @author tanghc
 * @date 17/1/18
 */
public abstract class AbstractorAopHandler implements AopHandler {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public boolean handler(ProceedingJoinPoint pjp) {
        Object[] args = pjp.getArgs();
        // 拦截的方法
        Method method = ((MethodSignature) pjp.getSignature()).getMethod();
        // 拦截的类名
        String className = pjp.getTarget().getClass().getSimpleName();
        return doHandler(pjp, args, method, className);
    }

    protected abstract boolean doHandler(ProceedingJoinPoint pjp, Object[] args, Method method, String className);
}
